<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class BoxRetreat extends Model
{
    public $table = 'box_retreat';

    protected $fillable = [
        'pic',
        'status',
        'demand',
        'reason',
        'type'
    ];

    public  function Box()
    {
        return $this->hasOne(Box::class,'id','box_id');
    }


    public  function user()
    {
        return $this->hasOne(UsersWechat::class,'id','wechat_id');
    }

    public function getPicAttribute()
    {
        $arrPic = unserialize($this->attributes['pic']);
        foreach ($arrPic as $key => $value) {
            $value = url($value);
        }
        return $arrPic;
    }

}
